//
//  HeroDetailView.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/19.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "HeroDetailView.h"

@implementation HeroDetailView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


-(instancetype)initWithFrame:(CGRect)frame andHero:(HeroDetailModel *)heroDetail
{

    self = [super initWithFrame:frame];
    if (self) {
      
        [self createSubViews:heroDetail];
    }

    return self;

}

-(void)dealloc
{
    [_heroDetail release];
    [_enName release];
    [_descriptionL release];
    [_descriptionL1 release];
    [_tipsLabel1 release];
    [_opponentTipsLabel1 release];
    [_hateimageV1 release];
    [_hateimageV2 release];
    [_hateDesL1 release];
    [_hateDesL2 release];
    [_skill release];
    [_skillView release];
    [_scrollV release];
    [_myImageV release];
    [_displayNameLabel release];
    [_tagsLabel release];
    [_priceLabel release];
    [_skillDataLabel release];
    [_Viktor_B release];
    [_Viktor_Q release];
    [_Viktor_W release];
    [_Viktor_E release];
    [_Viktor_R release];
    [_partnerLabel release];
    [_hateLabel release];
    [_partenerView release];
    [_partenerImage1 release];
    [_partenerImage2 release];
    [_partenerDesL1 release];
    [_partenerDesL2 release];
    [_tipsLabel release];
    [_opponentTipsLabel release];
    [_tipsView release];
    [_opponentView release];
    [_descriptionButton release];
    [_descriptionView release];
    [super dealloc];


}




-(void)createSubViews:(HeroDetailModel *)heroDetail
{

    UIImageView *backGround = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    backGround.backgroundColor = [UIColor groupTableViewBackgroundColor];
    backGround.alpha = 0.5;
    [backGround sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://box.dwstatic.com/skin/%@/%@_0.jpg",heroDetail.name,heroDetail.name]]];
    
    [self addSubview:backGround];
    [backGround release];
    
    
    
    

    self.scrollV = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.scrollV.backgroundColor = [UIColor clearColor];
    
    
    [self addSubview:self.scrollV];
    [_scrollV release];
    
       
    self.myImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, self.scrollV.frame.origin.y + 20 , 85, 85)];
    self.myImageV.backgroundColor = [UIColor whiteColor];
    
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",heroDetail.name]];
    [self.myImageV sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    [self.scrollV addSubview:self.myImageV];
    [_myImageV release];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-50, 20, 30, 30);
    self.button.backgroundColor = [UIColor clearColor];
    [self.button addTarget:self action:@selector(buttonAction1:) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollV addSubview:self.button];
    
    UIImage *image = [UIImage imageNamed:@"57b9a7f4a14f78c6e93c2a9a38c75aa0 下午2.51.04.png"];
    UIImageView *imageV = [[UIImageView alloc] initWithImage:image];
    imageV.frame =CGRectMake(0, 0, 30, 30);
    [self.button addSubview:imageV];
    
    
    
    
    
    self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myImageV.frame.origin.x + self.myImageV.frame.size.width + 5, self.myImageV.frame.origin.y, 120, 30)];
    self.displayNameLabel.backgroundColor = [UIColor clearColor];
    self.displayNameLabel.text = heroDetail.displayName;
    [self.scrollV addSubview:self.displayNameLabel];
    [_displayNameLabel release];
    
    self.tagsLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.displayNameLabel.frame.origin.x, self.displayNameLabel.frame.origin.y + self.displayNameLabel.frame.size.height, 30, 25)];
    self.tagsLabel.backgroundColor = [UIColor clearColor];
    self.tagsLabel.textColor = [UIColor lightGrayColor];
    
    
    self.tagsLabel.text = heroDetail.tags;
    self.tagsLabel.font = [UIFont systemFontOfSize:15];
    [self.scrollV addSubview:self.tagsLabel];
    [_tagsLabel release];
    
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tagsLabel.frame.origin.x + self.tagsLabel.frame.size.width + 5, self.tagsLabel.frame.origin.y, 120, 25)];
    self.priceLabel.backgroundColor = [UIColor clearColor];
    self.priceLabel.textColor = [UIColor lightGrayColor];
    
    
    NSArray *array = [heroDetail.price componentsSeparatedByString:@","];
    
    NSString *price= [array firstObject];
    
    NSString *price1 = [array lastObject];
        self.priceLabel.text = [NSString stringWithFormat:@"金:%@ 券:%@",price,price1];
    
    self.priceLabel.font = [UIFont systemFontOfSize:15];
    [self.scrollV addSubview:self.priceLabel];
    [_priceLabel release];
    
    self.skillDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myImageV.frame.origin.x, self.myImageV.frame.origin.y + self.myImageV.frame.size.height + 10, 200, 25)];
    self.skillDataLabel.backgroundColor = [UIColor clearColor];
    self.skillDataLabel.textColor = [UIColor lightGrayColor];
    self.skillDataLabel.font = [UIFont systemFontOfSize:15];
    self.skillDataLabel.text = @"技能介绍(点击图标查看详情)";
    [self.scrollV addSubview:self.skillDataLabel];
  
    self.Viktor_B = [UIButton buttonWithType:UIButtonTypeCustom];
    
    self.Viktor_B.frame = CGRectMake(self.skillDataLabel.frame.origin.x, self.skillDataLabel.frame.origin.y + self.skillDataLabel.frame.size.height + 5,  (self.scrollV.frame.size.width - 20 - 20) / 5, (self.scrollV.bounds.size.width - 20 - 20) / 5);
   
    
    
    NSString *str = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_B_64x64.png",heroDetail.name];
    [DownLoanImage downLoadImageUrl:str block:^(NSData *data) {
        [self.Viktor_B setBackgroundImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
        
    }];
    self.Viktor_B.backgroundColor = [UIColor clearColor];
    [self.Viktor_B addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.Viktor_B.userInteractionEnabled = YES;
    [self.scrollV addSubview:self.Viktor_B];

    self.Viktor_Q = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Viktor_Q.frame = CGRectMake(self.Viktor_B.frame.origin.x + self.Viktor_B.frame.size.width + 5, self.Viktor_B.frame.origin.y, self.Viktor_B.frame.size.width, self.Viktor_B.frame.size.height);
    self.Viktor_Q.backgroundColor = [UIColor clearColor];
    NSString *strQ = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_Q_64x64.png",heroDetail.name];
    [DownLoanImage downLoadImageUrl:strQ block:^(NSData *data) {
        [self.Viktor_Q setBackgroundImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
        
    }];

    [self.Viktor_Q addTarget:self action:@selector(buttonActionQ:) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollV addSubview:self.Viktor_Q];
    
    self.Viktor_W = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Viktor_W.frame = CGRectMake(self.Viktor_Q.frame.origin.x + self.Viktor_Q.frame.size.width + 5, self.Viktor_Q.frame.origin.y, self.Viktor_Q.frame.size.width, self.Viktor_Q.frame.size.height);
    self.Viktor_W.backgroundColor = [UIColor clearColor];
    NSString *strW = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_W_64x64.png",heroDetail.name];
    NSLog(@"------%@",strW);

    [DownLoanImage downLoadImageUrl:strW block:^(NSData *data) {
        [self.Viktor_W setBackgroundImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
        
    }];

    [self.Viktor_W addTarget:self action:@selector(buttonActionW:) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollV addSubview:self.Viktor_W];
    
    self.Viktor_E = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Viktor_E.frame = CGRectMake(self.Viktor_W.frame.origin.x + self.Viktor_W.frame.size.width + 5, self.Viktor_W.frame.origin.y, self.Viktor_W.frame.size.width, self.Viktor_W.frame.size.height);
    self.Viktor_E.backgroundColor = [UIColor clearColor];
    NSString *strE = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_E_64x64.png",heroDetail.name];
    
    NSLog(@"------%@",strE);
    
    [DownLoanImage downLoadImageUrl:strE block:^(NSData *data) {
        [self.Viktor_E setBackgroundImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
        
    }];

    [self.Viktor_E addTarget:self action:@selector(buttonActionE:) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollV addSubview:self.Viktor_E];
    
    self.Viktor_R = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Viktor_R.frame = CGRectMake(self.Viktor_E.frame.origin.x + self.Viktor_E.frame.size.width + 5, self.Viktor_E.frame.origin.y, self.Viktor_E.frame.size.width, self.Viktor_E.frame.size.height);
    self.Viktor_R.backgroundColor = [UIColor clearColor];
    NSString *strR = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_R_64x64.png",heroDetail.name];
    [DownLoanImage downLoadImageUrl:strR block:^(NSData *data) {
        [self.Viktor_R setBackgroundImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
        
    }];

    [self.Viktor_R addTarget:self action:@selector(buttonActionR:) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollV addSubview:self.Viktor_R];
    
 
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction1)];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction2)];
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction3)];
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction4)];
    
    
    self.partnerLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.Viktor_B.frame.origin.x, self.Viktor_B.frame.origin.y + self.Viktor_B.frame.size.height + 10, 200, 25)];
    self.partnerLabel.backgroundColor = [UIColor clearColor];
    self.partnerLabel.textColor = [UIColor lightGrayColor];
    self.partnerLabel.text = @"最佳搭档";
    [self.scrollV addSubview:self.partnerLabel];
    [_partnerLabel release];
    
    
    if (heroDetail.like.count != 0) {
        
        _dic = [heroDetail.like firstObject];
        _dic1 = [heroDetail.like lastObject];
       
    }
    
    
    NSURL *urllike = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",[self.dic objectForKey:@"partner"]]];
    self.partenerImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(self.partnerLabel.frame.origin.x, self.partnerLabel.frame.origin.y + self.partnerLabel.frame.size.height + 5, 64, 64)];
    [self.partenerImage1 sd_setImageWithURL:urllike placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    self.partenerImage1.backgroundColor = [UIColor whiteColor];
    self.partenerImage1.userInteractionEnabled = YES;
    [self.partenerImage1 addGestureRecognizer:tap1];
    [self.scrollV addSubview:self.partenerImage1];
    [_partenerImage1 release];
    [tap1 release];
    
    self.partenerDesL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.partenerImage1.frame.origin.x + self.partenerImage1.frame.size.width + 3, self.partenerImage1.frame.origin.y,self.scrollV.frame.size.width - self.partenerImage1.frame.size.width - 40, 130)];
    self.partenerDesL1.text = [self.dic objectForKey:@"des"];
    self.partenerDesL1.numberOfLines = 0;
    
    self.partenerDesL1.font = [UIFont systemFontOfSize:13];
    self.partenerDesL1.backgroundColor = [UIColor clearColor];
    

    
    
    [self.scrollV addSubview:self.partenerDesL1];
    [_partenerDesL1 release];
    
    NSURL *urllike2 = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",[self.dic1 objectForKey:@"partner"]]];
    self.partenerImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(self.partenerImage1.frame.origin.x, self.partenerDesL1.frame.size.height + self.partenerDesL1.frame.origin.y + 5, 64, 64)];
    [self.partenerImage2 sd_setImageWithURL:urllike2 placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    self.partenerImage2.userInteractionEnabled = YES;
    [self.partenerImage2 addGestureRecognizer:tap2];
    self.partenerImage2.backgroundColor = [UIColor whiteColor];
    [self.scrollV addSubview:self.partenerImage2];
    [_partenerDesL1 release];
    [tap2 release];
    
    self.partenerDesL2 = [[UILabel alloc]initWithFrame:CGRectMake(self.partenerDesL1.frame.origin.x, self.partenerImage2.frame.origin.y, self.partenerDesL1.frame.size.width, self.partenerDesL1.frame.size.height)];
    self.partenerDesL2.text = [self.dic1 objectForKey:@"des"];
    self.partenerDesL2.font = [UIFont systemFontOfSize:13];
    self.partenerDesL2.backgroundColor = [UIColor clearColor];
    self.partenerDesL2.numberOfLines = 0;
    [self.scrollV addSubview:self.partenerDesL2];
    [_partenerDesL2 release];
    
    self.hateLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.partenerImage2.frame.origin.x, self.partenerDesL2.frame.origin.y + self.partenerDesL2.frame.size.height + 10, 200, 25)];
    self.hateLabel.backgroundColor = [UIColor clearColor];
    self.hateLabel.textColor = [UIColor lightGrayColor];
    self.hateLabel.text = @"最佳克制";
    [self.scrollV addSubview:self.hateLabel];
    [_hateLabel release];
    
    if (heroDetail.hate.count != 0) {
        
        _Dic = [heroDetail.hate firstObject];
        _Dic1 = [heroDetail.hate lastObject];
        
    }
    NSURL *urlhate = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",[self.Dic objectForKey:@"partner"]]];
    self.hateimageV1 = [[UIImageView alloc] initWithFrame:CGRectMake(self.hateLabel.frame.origin.x, self.hateLabel.frame.origin.y + self.hateLabel.frame.size.height + 5, 64, 64)];
    [self.hateimageV1 sd_setImageWithURL:urlhate placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    self.hateimageV1.backgroundColor = [UIColor clearColor];
    self.hateimageV1.userInteractionEnabled = YES;
    [self.hateimageV1 addGestureRecognizer:tap3];
    [self.scrollV addSubview:self.hateimageV1];
    [_hateimageV1 release];
    [tap3 release];
    
    self.hateDesL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.hateimageV1.frame.origin.x + self.hateimageV1.frame.size.width + 3, self.hateimageV1.frame.origin.y,self.scrollV.frame.size.width - self.partenerImage1.frame.size.width - 40, 130)];
    self.hateDesL1.numberOfLines = 0;
    self.hateDesL1.text = [self.Dic objectForKey:@"des"];
    self.hateDesL1.font = [UIFont systemFontOfSize:13];
    self.hateDesL1.backgroundColor = [UIColor clearColor];
    [self.scrollV addSubview:self.hateDesL1];
    [_hateDesL1 release];
    
    NSURL *urlhate1 = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",[self.Dic1 objectForKey:@"partner"]]];
    self.hateimageV2 = [[UIImageView alloc] initWithFrame:CGRectMake(self.hateimageV1.frame.origin.x, self.hateDesL1.frame.size.height + self.hateDesL1.frame.origin.y + 5, 64, 64)];
    [self.hateimageV2 sd_setImageWithURL:urlhate1 placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    self.hateimageV2.backgroundColor = [UIColor clearColor];
    self.hateimageV2.userInteractionEnabled = YES;
    [self.hateimageV2 addGestureRecognizer:tap4];
    [self.scrollV addSubview:self.hateimageV2];
    [_hateimageV2 release];
    [tap4 release];
    
    self.hateDesL2 = [[UILabel alloc]initWithFrame:CGRectMake(self.hateDesL1.frame.origin.x, self.hateimageV2.frame.origin.y, self.hateDesL1.frame.size.width, self.hateDesL1.frame.size.height)];
    self.hateDesL2.backgroundColor = [UIColor clearColor];
    self.hateDesL2.text = [self.Dic1 objectForKey:@"des"];
    self.hateDesL2.textAlignment =  NSTextAlignmentNatural;
    self.hateDesL2.font = [UIFont systemFontOfSize:13];
    self.hateDesL2.numberOfLines = 0;
    [self.scrollV addSubview:self.hateDesL2];
    [_hateDesL2 release];
   
    self.tipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.hateimageV2.frame.origin.x, self.hateDesL2.frame.origin.y + self.hateDesL2.frame.size.height + 10, 50, 25)];
    self.tipsLabel.backgroundColor = [UIColor clearColor];
    self.tipsLabel.text = @"使用";
    self.tipsLabel.textColor = [UIColor lightGrayColor];
    [self.scrollV addSubview:self.tipsLabel];
    [_tipsLabel release];
    
    self.tipsLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(self.tipsLabel.frame.origin.x, self.tipsLabel.frame.origin.y + self.tipsLabel.frame.size.height + 5, self.scrollV.bounds.size.width - 20, 80)];
    self.tipsLabel1.backgroundColor = [UIColor clearColor];
    self.tipsLabel1.numberOfLines = 0;
    self.tipsLabel1.text = heroDetail.tips;
    self.tipsLabel1.font = [UIFont systemFontOfSize:16];
   CGFloat height = [self heightOfMe:self.tipsLabel1.text];
    CGRect frame = self.tipsLabel1.frame;
    frame.size.height = height;
    self.tipsLabel1.frame = frame;
    
    [self.scrollV addSubview:self.tipsLabel1];
    [_tipsLabel1 release];
    
    self.opponentTipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tipsLabel1.frame.origin.x, self.tipsLabel1.frame.origin.y + self.tipsLabel1.frame.size.height + 10, 50, 25)];
    self.opponentTipsLabel.backgroundColor = [UIColor clearColor];
    self.opponentTipsLabel.text = @"应对";
    self.opponentTipsLabel.textColor = [UIColor lightGrayColor];
    [self.scrollV addSubview:self.opponentTipsLabel];
    [_opponentTipsLabel release];
    
    self.opponentTipsLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(self.opponentTipsLabel.frame.origin.x, self.opponentTipsLabel.frame.origin.y + self.opponentTipsLabel.frame.size.height + 5, self.scrollV.bounds.size.width - 20, 80)];
    self.opponentTipsLabel1.backgroundColor = [UIColor clearColor];
    self.opponentTipsLabel1.numberOfLines = 0;
    self.opponentTipsLabel1.text = heroDetail.opponentTips;
    self.opponentTipsLabel1.font = [UIFont systemFontOfSize:16];
   CGFloat height1 = [self heightOfMe:self.opponentTipsLabel1.text];
    CGRect frame1 = self.opponentTipsLabel1.frame;
    frame1.size.height = height1;
    self.opponentTipsLabel1.frame = frame1;
    
    [self.scrollV addSubview:self.opponentTipsLabel1];
    [_opponentTipsLabel1 release];

    self.descriptionL = [[UILabel alloc] initWithFrame:CGRectMake(self.opponentTipsLabel1.frame.origin.x, self.opponentTipsLabel1.frame.origin.y + self.opponentTipsLabel1.frame.size.height + 10, 90, 25)];
    self.descriptionL.backgroundColor = [UIColor clearColor];
    self.descriptionL.text = @"背景故事";
    self.descriptionL.textColor = [UIColor lightGrayColor];
    [self.scrollV addSubview:self.descriptionL];
    [_descriptionL release];
    
    self.descriptionL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.descriptionL.frame.origin.x, self.descriptionL.frame.origin.y + self.descriptionL.frame.size.height , self.scrollV.bounds.size.width - 20, 80)];
    self.descriptionL1.backgroundColor = [UIColor clearColor];
    self.descriptionL1.text = heroDetail.miaoshu;
    self.descriptionL1.numberOfLines = 0;
    self.descriptionL1.font = [UIFont systemFontOfSize:16];
   CGFloat height2 = [self heightOfMe:self.descriptionL1.text];
    CGRect frame2 = self.descriptionL1.frame;
    frame2.size.height = height2;
    self.descriptionL1.frame = frame2;
    
    [self.scrollV addSubview:self.descriptionL1];
    [_descriptionL1 release];

     self.heroDetail = heroDetail;
    
    self.skillView = [[UIView alloc] initWithFrame:CGRectMake(-self.scrollV.bounds.size.width, self.Viktor_B.frame.origin.y, self.scrollV.frame.size.width, self.scrollV.frame.size.height)];
    self.skillView.backgroundColor = [UIColor clearColor];
    [self.scrollV addSubview:self.skillView];
    [_skillView release];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    self.skill = [[UIView alloc] initWithFrame:CGRectMake(-375, self.Viktor_B.frame.origin.y,self.skillView.frame.size.width - 60, 80)];
    
    self.skill.backgroundColor = [UIColor lightGrayColor];
    [self.skillView addSubview:self.skill];
    [_skill release];
    
    self.backImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height)];
    self.backImage.image = [UIImage imageNamed:@"7cfe85ee8602ec539eac4345fffe8c00.jpg"];
    self.backImage.alpha = 0.5;
    self.backImage.userInteractionEnabled = YES;
    [self.backImage addGestureRecognizer:tap];
    [self.skill addSubview:self.backImage];
    [_backImage release];
    [tap release];
    
    
    
    
    self.titleS = [[UILabel alloc] initWithFrame:CGRectMake( 5,  5, self.skill.frame.size.width - 10, 20)];
    self.titleS.backgroundColor = [UIColor clearColor];
    
    [self.skill addSubview:self.titleS];
    [_titleS release];
    
    self.costL = [[UILabel alloc] initWithFrame:CGRectMake(self.titleS.frame.origin.x, self.titleS.frame.origin.y + self.titleS.frame.size.height + 3, 30, 20)];
    self.costL.backgroundColor = [UIColor clearColor];
    self.costL.text = @"消耗:";
    self.costL.font = [UIFont systemFontOfSize:13];
    [self.skill addSubview:self.costL];
    [_costL release];
    
    self.costL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.costL.frame.origin.x + self.costL.frame.size.width + 3, self.costL.frame.origin.y, self.titleS.frame.size.width - self.costL.frame.size.width - 3, self.titleS.frame.size.height)];
    self.costL1.font = [UIFont systemFontOfSize:13];
    self.costL1.backgroundColor = [UIColor clearColor];
    
    [self.skill addSubview:self.costL1];
    [_costL1 release];
    
    self.rangeL = [[UILabel alloc] initWithFrame:CGRectMake(self.costL.frame.origin.x, self.costL.frame.origin.y + self.costL.frame.size.height + 3, self.costL.frame.size.width, self.costL.frame.size.height)];
    self.rangeL.backgroundColor = [UIColor clearColor];
    self.rangeL.text = @"范围:";
    self.rangeL.font = [UIFont systemFontOfSize:13];
    [self.skill addSubview:self.rangeL];
    [_rangeL release];
    
    self.range = [[UILabel alloc] initWithFrame:CGRectMake(self.rangeL.frame.origin.x + self.rangeL.frame.size.width + 3, self.rangeL.frame.origin.y, self.costL1.frame.size.width, self.costL1.frame.size.height)];
    self.range.backgroundColor = [UIColor clearColor];
    self.range.font = [UIFont systemFontOfSize:13];
    
    [self.skill addSubview:self.range];
    [_range release];
    
    self.cooldownL = [[UILabel alloc] initWithFrame:CGRectMake(self.rangeL.frame.origin.x, self.rangeL.frame.origin.y + self.rangeL.frame.size.height + 3, self.rangeL.frame.size.width, self.rangeL.frame.size.height)];
    self.cooldownL.backgroundColor = [UIColor clearColor];
    self.cooldownL.font = [UIFont systemFontOfSize:13];
    self.cooldownL.text = @"冷却:";
    [self.skill addSubview:self.cooldownL];
    [_cooldownL release];
    
    self.cooldownL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.cooldownL.frame.origin.x + self.cooldownL.frame.size.width + 3, self.cooldownL.frame.origin.y, self.range.frame.size.width, self.range.frame.size.height)];
    self.cooldownL1.backgroundColor = [UIColor clearColor];
    self.cooldownL1.font = [UIFont systemFontOfSize:13];
    
    [self.skill addSubview:self.cooldownL1];
    [_cooldownL1 release];
    
    self.effectL = [[UILabel alloc] initWithFrame:CGRectMake(self.cooldownL.frame.origin.x, self.cooldownL.frame.origin.y + self.cooldownL.frame.size.height + 3, self.cooldownL.frame.size.width, self.cooldownL.frame.size.height)];
    self.effectL.backgroundColor = [UIColor clearColor];
    self.effectL.font = [UIFont systemFontOfSize:13];
    self.effectL.text = @"效果:";
    [self.skill addSubview:self.effectL];
    [_effectL release];
    
    self.effectL1 = [[UILabel alloc] initWithFrame:CGRectMake(self.effectL.frame.origin.x + self.effectL.frame.size.width + 3, self.effectL.frame.origin.y + 3, self.cooldownL1.frame.size.width, 80)];
    self.effectL1.numberOfLines = 0;
    self.effectL1.backgroundColor = [UIColor clearColor];
    self.effectL1.font = [UIFont systemFontOfSize:13];
    
    [self.skill addSubview:self.effectL1];
    [_effectL1 release];
    
    
    self.descriptionLA = [[UILabel alloc] initWithFrame:CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height)];
    self.descriptionLA.backgroundColor = [UIColor clearColor];
    self.descriptionLA.font = [UIFont systemFontOfSize:13];
    self.descriptionLA.text = @"描述:";
    [self.skill addSubview:self.descriptionLA];
    [_descriptionLA release];
    
    self.descriptionLA1 = [[UILabel alloc] initWithFrame:CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height)];
    self.descriptionLA1.backgroundColor = [UIColor clearColor];
    self.descriptionLA1.numberOfLines = 0;
    
    

    self.descriptionLA1.font = [UIFont systemFontOfSize:13];
    [self.skill addSubview:self.descriptionLA1];
    [_descriptionLA1 release];
    

    
    
    self.scrollV.contentSize = CGSizeMake(self.window.bounds.size.width, self.descriptionL1.frame.origin.y + self.descriptionL1.frame.size.height + 64 + 55);
    
   
    
}



-(void)buttonAction1:(UIButton *)button
{
    

    [[collect shareData]openColl];
    NSMutableArray *array = [[collect shareData]selectAll];  
    for (HeroDetailModel *hero in array) {
        if ([self.heroDetail.displayName isEqualToString:hero.displayName]) {
            
             UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"已经收藏过!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
            [alert show];
            
            
            return;
        }
        
        }

    
    
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"是否收藏?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
    
    
    
    
    
    
    
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1) {
        
        [[collect shareData]openColl];//打开数据库
        [[collect shareData]createTable];//创建表
        [[collect shareData]insertHero:self.heroDetail];//插入
        
        
    }
    
    
}

-(void)tapAction1
{

    
    [self.myDelegate presentSecond:[self.dic objectForKey:@"partner"]];
    
}

-(void)tapAction2
{
    [self.myDelegate presentSecond:[self.dic1 objectForKey:@"partner"]];

    
}
-(void)tapAction3
{
    
    [self.myDelegate presentSecond:[self.Dic objectForKey:@"partner"]];

    
}
-(void)tapAction4
{
    [self.myDelegate presentSecond:[self.Dic1 objectForKey:@"partner"]];

}







-(void)tapAction
{

    [UIView animateWithDuration:0.3 animations:^{
        
        
        self.skill.frame = CGRectMake(-375, self.Viktor_B.frame.origin.y, 0, 0);
        self.skillView.frame = CGRectMake(-375, self.Viktor_B.frame.origin.y, 0, 0);
        
    }];
    

}

-(void)buttonActionQ:(UIButton *)myButton
{
    [UIView animateWithDuration:0.3 animations:^{
        
        self.skillView.frame = [[UIScreen mainScreen] bounds];
        self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, 400);
        
        
        self.titleS.text = [NSString stringWithFormat:@"Q:%@",[self.heroDetail.Q objectForKey:@"name"]];
        self.costL1.text = [self.heroDetail.Q objectForKey:@"cost"];
        self.cooldownL1.text = [self.heroDetail.Q objectForKey:@"cooldown"];
        self.descriptionLA1.text = [self.heroDetail.Q objectForKey:@"description"];
        self.range.text = [self.heroDetail.Q objectForKey:@"range"];
        self.effectL1.text = [self.heroDetail.Q objectForKey:@"effect"];
        
        CGFloat H = [self heightOfText:self.effectL1.text];
        CGRect fr = self.effectL1.frame;
        fr.size.height = H;
        self.effectL1.frame = fr;
        
        self.descriptionLA.frame =CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + self.effectL.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height);
        
        self.descriptionLA1.frame =
        CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height);
        
        CGFloat he = [self heightOfText:self.descriptionLA1.text];
        CGRect fram = self.descriptionLA1.frame;
        fram.size.height = he;
        self.descriptionLA1.frame = fram;
        
        self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, self.descriptionLA1.frame.size.height + self.descriptionLA1.frame.origin.y + 5);
        self.backImage.frame = CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height);
        
    }];
    
}
-(void)buttonActionW:(UIButton *)myButton
{

    self.skillView.frame = [[UIScreen mainScreen] bounds];
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, 400);
    
    
    self.titleS.text = [NSString stringWithFormat:@"W:%@",[self.heroDetail.W objectForKey:@"name"]];
    self.costL1.text = [self.heroDetail.W objectForKey:@"cost"];
    self.cooldownL1.text = [self.heroDetail.W objectForKey:@"cooldown"];
    self.descriptionLA1.text = [self.heroDetail.W objectForKey:@"description"];
    self.range.text = [self.heroDetail.W objectForKey:@"range"];
    self.effectL1.text = [self.heroDetail.W objectForKey:@"effect"];
    
    CGFloat H = [self heightOfText:self.effectL1.text];
    CGRect fr = self.effectL1.frame;
    fr.size.height = H;
    self.effectL1.frame = fr;
    
    self.descriptionLA.frame =CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + self.effectL.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height);
    
    self.descriptionLA1.frame =
    CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height);
    
    CGFloat he = [self heightOfText:self.descriptionLA1.text];
    CGRect fram = self.descriptionLA1.frame;
    fram.size.height = he;
    self.descriptionLA1.frame = fram;
    
self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, self.descriptionLA1.frame.size.height + self.descriptionLA1.frame.origin.y + 5);
    self.backImage.frame = CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height);


    
}
-(void)buttonActionE:(UIButton *)myButton
{


    self.skillView.frame = [[UIScreen mainScreen] bounds];
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, 400);
    

    self.titleS.text = [NSString stringWithFormat:@"E:%@",[self.heroDetail.E objectForKey:@"name"]];
    self.costL1.text = [self.heroDetail.E objectForKey:@"cost"];
    self.cooldownL1.text = [self.heroDetail.E objectForKey:@"cooldown"];
    self.descriptionLA1.text = [self.heroDetail.E objectForKey:@"description"];
    self.range.text = [self.heroDetail.E objectForKey:@"range"];
    self.effectL1.text = [self.heroDetail.E objectForKey:@"effect"];
    
    CGFloat H = [self heightOfText:self.effectL1.text];
    CGRect fr = self.effectL1.frame;
    fr.size.height = H;
    self.effectL1.frame = fr;
    
    self.descriptionLA.frame =CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + self.effectL.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height);

    self.descriptionLA1.frame =
    CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height);
    
    CGFloat he = [self heightOfText:self.descriptionLA1.text];
    CGRect fram = self.descriptionLA1.frame;
    fram.size.height = he;
    self.descriptionLA1.frame = fram;

    
    
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, self.descriptionLA1.frame.size.height + self.descriptionLA1.frame.origin.y + 5);
    self.backImage.frame = CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height);

    
   }
-(void)buttonActionR:(UIButton *)myButton
{

    self.skillView.frame = [[UIScreen mainScreen] bounds];
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, 400);
    
    
    self.titleS.text = [NSString stringWithFormat:@"R:%@",[self.heroDetail.R objectForKey:@"name"] ];
    self.costL1.text = [self.heroDetail.R objectForKey:@"cost"];
    self.cooldownL1.text = [self.heroDetail.R objectForKey:@"cooldown"];
    self.descriptionLA1.text = [self.heroDetail.R objectForKey:@"description"];
    self.range.text = [self.heroDetail.R objectForKey:@"range"];
    self.effectL1.text = [self.heroDetail.R objectForKey:@"effect"];
    
    CGFloat H = [self heightOfText:self.effectL1.text];
    CGRect fr = self.effectL1.frame;
    fr.size.height = H;
    self.effectL1.frame = fr;
    
    self.descriptionLA.frame =CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + self.effectL.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height);

    
    self.descriptionLA1.frame =
    CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height);
    
    CGFloat he = [self heightOfText:self.descriptionLA1.text];
    CGRect fram = self.descriptionLA1.frame;
    fram.size.height = he;
    self.descriptionLA1.frame = fram;
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, self.descriptionLA1.frame.size.height + self.descriptionLA1.frame.origin.y + 5);
    self.backImage.frame = CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height);

}
-(void)buttonAction:(UIButton *)myButton
{
    
    self.skillView.frame = [[UIScreen mainScreen] bounds];
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, 400);
    
    
    self.titleS.text = [NSString stringWithFormat:@"B:%@",[self.heroDetail.B objectForKey:@"name"] ];
    self.costL1.text = [self.heroDetail.B objectForKey:@"cost"];
    self.cooldownL1.text = [self.heroDetail.B objectForKey:@"cooldown"];
    self.descriptionLA1.text = [self.heroDetail.B objectForKey:@"description"];
    self.range.text = [self.heroDetail.B objectForKey:@"range"];
    self.effectL1.text = [self.heroDetail.B objectForKey:@"effect"];
    
    CGFloat H = [self heightOfText:self.effectL1.text];
    CGRect fr = self.effectL1.frame;
    fr.size.height = H;
    self.effectL1.frame = fr;
    
    self.descriptionLA.frame =CGRectMake(self.effectL.frame.origin.x, self.effectL1.frame.origin.y + self.effectL1.frame.size.height + self.effectL.frame.size.height + 3, self.effectL.frame.size.width, self.effectL.frame.size.height);
    
    self.descriptionLA1.frame =
    CGRectMake(self.descriptionLA.frame.origin.x + self.descriptionLA.frame.size.width + 3, self.descriptionLA.frame.origin.y , self.effectL1.frame.size.width, self.effectL1.frame.size.height);
    
    CGFloat he = [self heightOfText:self.descriptionLA1.text];
    CGRect fram = self.descriptionLA1.frame;
    fram.size.height = he;
    self.descriptionLA1.frame = fram;
    
    self.skill.frame = CGRectMake(30, 40, self.skillView.frame.size.width - 60, self.descriptionLA1.frame.size.height + self.descriptionLA1.frame.origin.y + 5);
    self.backImage.frame = CGRectMake(0, 0, self.skill.frame.size.width, self.skill.frame.size.height);
    
   
    
}

-(CGFloat)heightOfMe:(NSString *)text
{
    
    CGSize size = CGSizeMake(self.scrollV.bounds.size.width - 20, 10000);
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];;
    
    return frame.size.height;
    
    
}

-(CGFloat)heightOfText:(NSString *)text
{
    
    CGSize size = CGSizeMake(self.titleS.frame.size.width - self.costL.frame.size.width - 3, 10000);
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:13] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];;
    
    return frame.size.height;
}

-(CGFloat)heightOfMe1:(NSString *)text
{
    
    CGSize size = CGSizeMake(self.scrollV.frame.size.width - self.partenerImage1.frame.size.width - 40, 10000);
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];;
    
    return frame.size.height;
    
    
}



@end
